<template>
  <div class="topic">
    <div class="topicdetail">
      <p class="topicimgbox"><img :src="list.coverMobileUrl" alt="" /></p>
      <p class="title">#{{ list.title }}#</p>
      <p class="textp" v-if="list.text">{{ list.text[0] }}</p>
      <p class="textp" v-if="list.text">{{ list.text[1] }}</p>
      <p class="textp" v-if="list.text">{{ list.text[2] }}</p>
    </div>
    <div class="combox">
      <p class="hot"><span>热门评论</span></p>
      <div class="usercom" v-for="(item, index) in infos" :key="index">
        <div class="user">
          <div class="infobox">
            <div class="avabox">
              <img :src="item.user.avatarUrl" alt="" class="avaimg" />
            </div>
            <span class="nickname">{{ item.user.nickname }}</span>
            <span v-if="datas[index].song" class="share">分享单曲：</span>
          </div>
          <span class="song" v-if="datas[index].song"
            >#{{ datas[index].song.name }}#</span
          >
          <p class="msg">{{ datas[index].msg }}</p>
          <div class="shareimg">
            <img
              :src="datas[index].song.album.blurPicUrl"
              alt=""
              v-if="datas[index].song"
            />
            <img
              :src="datas[index].resource.coverImgUrl"
              alt=""
              v-if="datas[index].resource"
            />
          </div>
          <p>
            <!-- <img :src="item.pics[0].originUrl" alt="" class="comimg" /> -->
          </p>
        </div>
        <div class="footer">
          <van-icon name="share-o" />
          <span class="shareCount">{{ item.info.shareCount }}</span>
          <van-icon name="chat-o" />
          <span class="commentCount">{{ item.info.commentCount }}</span>
          <van-icon name="good-job-o" />
          <span class="likedCount">{{ item.info.likedCount }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "../../../../axios/index";
export default {
  data() {
    return {
      list: [],
      infos: [],
      datas: [],
    };
  },
  computed: {},
  watch: {},

  methods: {
    loaddetail() {
      let actId = this.$route.params.id;
      axios
        .get(`/topic/detail?actid=${actId}`, { withcredentials: true })
        .then((res) => {
          // console.log(res);
          this.list = res.data.act;
        });
    },
    loaddata() {
      let actId = this.$route.params.id;
      axios
        .get(`/topic/detail/event/hot?actid=${actId}`, {
          withcredentials: true,
        })
        .then((res) => {
          console.log(res.data.events);
          this.infos = res.data.events;
          let arr = res.data.events;
          let dataArr = [];
          // console.log(arr);
          arr.forEach((v) => {
            let obj = JSON.parse(v.json);
            dataArr.push(obj);
          });
          console.log(dataArr);
          this.datas = dataArr;
        });
    },
  },
  created() {
    this.loaddetail();
    this.loaddata();
  },
  mounted() {},
  components: {},
};
</script>
<style scoped>
.hot {
  padding: 10px;
  font-size: 14px;
  font-family: "黑体";
  font-weight: 30000;
}
img {
  width: 100%;
}
.title {
  padding: 10px;
  font-style: 16px;
  margin-bottom: 15px;
  color: #6c8099;
}
.topicdetail p {
  padding: 10px 10px;
}
.topicdetail img {
  width: 100%;
}
.textp {
  font-size: 12px;
  color: #727272;
  line-height: 30px;
}
.avabox {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-block;
  margin-left: 10px;
}
.nickname {
  font-size: 14px;
  color: #6c8099;
  margin-left: 10px;
  margin-right: 5px;
}
.avaimg {
  width: 40px;
  height: 40px;
}
.msg {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  font-size: 12px;
  padding-left: 10px;
  padding-right: 10px;
  line-height: 27px;
  font-weight: 20;
  color: #2c2c2c;
}
.usercom {
  margin-top: 30px;
}
.combox {
  /* padding-bottom: 20px; */
}
.infobox {
  display: flex;
  align-items: center;
}
.song {
  color: #6c8099;
  font-size: 14px;
  font-weight: bold;
  margin-top: 15px;
  margin-bottom: 15px;
  display: block;
  padding-left: 10px;
}
.share {
  color: #616161;
  font-size: 14px;
}
.topicimgbox {
  padding: 0;
}
.topicimgbox img {
  width: 100%;
}
.shareimg {
  width: 340px;
  /* padding: 10px; */
  margin: 15px auto;
  border-radius: 10px !important;
  overflow: hidden;
}
.shareimg img {
  width: 100%;
}
.footer {
  padding: 10px;
  font-size: 12px;
  color: #606060;
}
.shareCount {
  margin-left: 5px;
  margin-right: 40px;
  color: #9c9c9c;
}
.commentCount {
  margin-left: 5px;
  margin-right: 40px;
  color: #9c9c9c;
}
.likedCount {
  margin-left: 5px;
  margin-right: 40px;
  color: #9c9c9c;
}
</style>
